@extends('layouts.app')
@include('order.sidebar')
@section('content')
    <div class="content">
        <div class="row custom-invoice">
            <div class="row">
                <form method="get" action="{{ route('admin.order.package_index') }}">
                    <div class="form-group col-md-2 col-sm-6 col-xs-10">
                        <input class="form-control" type="text" name="orderId" value="{{ $orderId }}" placeholder="订单ID">
                    </div>
                    <div class="form-group col-md-2 col-sm-6 col-xs-10">
                        <input class="form-control" type="text" name="name" value="{{ $name }}" placeholder="姓名">
                    </div>

                    <div class="form-group col-md-2 col-sm-6 col-xs-10">
                        <input class="form-control" type="text" name="mobile" value="{{ $mobile }}" placeholder="电话号">
                    </div>

                    <div class="form-group col-md-1 col-sm-3 col-xs-10">
                        <input type="checkbox" name="status[]" id="statusInit" value="{{ \App\Modules\Order\Models\Order::STATUS_INIT }}" {{ in_array('init', $status)? "checked":"" }}>
                        <label class="control-label" for="statusInit">待支付</label>
                    </div>
                    <div class="form-group col-md-1 col-sm-3 col-xs-10">
                        <input type="checkbox" name="status[]" id="statusPaid" value="{{ \App\Modules\Order\Models\Order::STATUS_PAID }}"  {{ in_array('paid', $status)? "checked":"" }}>
                        <label class="control-label" for="statusPaid">已支付</label>
                    </div>
                    <div class="form-group col-md-1 col-sm-3 col-xs-10">
                        <input type="checkbox" name="status[]" id="statusRefund" value="{{ \App\Modules\Order\Models\Order::STATUS_REFUND }}"  {{ in_array('refund', $status)? "checked":"" }}>
                        <label class="control-label" for="statusRefund">已退款</label>
                    </div>
                    <div class="form-group col-md-1 col-sm-3 col-xs-10">
                        <input type="checkbox" name="statusClose" id="statusClose" value="{{ \App\Modules\Order\Models\Order::STATUS_CLOSE }}" {{ in_array('close', $status)? "checked":"" }}>
                        <label class="control-label" for="statusClose">已关闭</label>
                    </div>

                    <div class="form-group col-md-2 col-sm-10 col-xs-10">
                        <button class="btn btn-success btn-ms" type="submit">搜索</button>
                    </div>
                </form>
            </div>
            <hr />
            <br />
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>下单时间</th>
                    <th>用户</th>
                    <th>头像</th>
                    <th>订单ID</th>
                    <th>套系名</th>
                    <th>所选产品</th>
                    <th>订单价格</th>
                    <th>退款金额</th>
                    <th>推荐人</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                @foreach($data as $item)
                <tbody>
                <tr>
                    <td>{{ $item->created_at }}</td>
                    <td>{{ $item->nickname }}</td>
                    <td>
                        <img src="{{ $item->avatar  }}" width="30">
                    </td>
                    <td>{{ $item->id }}</td>
                    <td>{{ $item->title }}</td>
                    <td>{{ $item->spec }}</td>
                    <td>{{ $item->price/100 }}</td>
                    <td>{{ $item->refund_fee/100 }}</td>
                    <td>{{ $referrer->get($item->referrer_id)?$referrer->get($item->referrer_id)->name : "" }}</td>
                    <td>{{ \App\Modules\Order\Models\Order::$statusShow[$item->status] }}</td>
                    <td>
                        <a class="btn btn-danger btn-xs refund" data-url="{{ route("admin.order.refund", ['id' => $item->id]) }}"><i class="fa fa-star"></i> 退款</a>
                        <a class="btn btn-success btn-xs" href="{{ route('admin.order.finish', ['id' => $item->id]) }}"><i class="fa fa-star"></i> 收到尾款</a>
                    </td>
                </tr>
                </tbody>
                @endforeach
            </table>
            {{ $data->appends(['orderId' => $orderId, 'mobile' => $mobile, 'status' => $status])->links() }}
        </div>
        <div class="modal fade loading custom-hide" id="hideForm" tabindex="-1" role="dialog" aria-labelledby="hideFormLibel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
            <div class="modal-dialog">
                <div class="content invoice" style="text-align: left">
                    <form class='form'  action="" method="POST">
                        <input type="hidden" name="_token" value="{{ csrf_token() }}" />
                        <div class="form-group">
                            <label for="money">退款金额：</label>
                            <input type = "text" name = "money" id = "money" required />
                        </div>
                        <div class="form-group">
                            <label for="reason">退款理由：</label>
                            <input type = "text" name = "reason" id = "reason" required />
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn btn-success form-control">提交</button>
                            <br />
                            <br />
                            <button type="button" class="btn" id="closeHideForm2">关闭</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection
@push('scripts')
    <script>

        $('.refund').on('click', function () {
            $("#hideForm form").attr('action', $(this).attr('data-url'));
            $("#hideForm").modal('show');
        });
        $('#closeHideForm').on('click', function () {
            $("#hideForm").modal('hide');
        });
    </script>
@endpush


